package com.anthonybennis.blender.client.pages.videos;

import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;

/**
 * 
 * @author abennis
 */
public class VideoTile 
{
	private final int WIDTH = 400;
	private final int HEIGHT = 239;
	
	/*
	 * Temp
	 */
	public static final String PILZ_VIDEO = "6PYbzjzKxoE";
	
	/**
	 * 
	 * @param videoURL
	 */
	protected Widget create(String videoURL)
	{
		final String html = this.generateHTMLCode(videoURL);
		final HTMLPanel htmlPanel = new HTMLPanel(html);
		htmlPanel.setStyleName("html-panel");
		
		return htmlPanel;
	}
	
	/**
	 * <iframe width="100%" height="215" src="http://www.youtube.com/embed/**********?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
	 * @return
	 */
	private String generateHTMLCode(String videoURL)
	{
		final StringBuilder htmlStringBuilder = new StringBuilder();
		
		htmlStringBuilder.append("<iframe width=\"");
		htmlStringBuilder.append(WIDTH);
		htmlStringBuilder.append("\" height=\"");
		htmlStringBuilder.append(HEIGHT);
		htmlStringBuilder.append("\" src=\"//www.youtube.com/embed/");
		htmlStringBuilder.append(videoURL);
		htmlStringBuilder.append("\" frameborder=\"0\" allowfullscreen></iframe>");
		//<a href="http://m.youtube.com?docid=YBBHKKHLqyI&action=playback"><img src="http://i2.ytimg.com/vi/YBBHKKHLqyI/default.jpg"></a>
		return htmlStringBuilder.toString();
	}
}